//
//  EpointUIUtils.m
//  EpointFrame5
//  
//  Created by 李亚春 on 13-12-17.
//  Copyright (c) 2013年 Epoint. All rights reserved.
//

#import "EpointUIUtils.h"

@implementation EpointUIUtils

+(CGRect)getAppLoadFrame
{
    return CGRectMake(0, 0, AppWidth, AppHeight-64);
}

+(UILabel *)getFeedBackLabel:(NSString *)textStr
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)];
    //设置自动行数与字符换行，为0标示无限制
    [label setNumberOfLines:0];
    label.lineBreakMode = NSLineBreakByWordWrapping;//换行方式
    UIFont *font = [UIFont fontWithName:@"Arial" size:13];
    label.backgroundColor = [UIColor clearColor];
    label.font = font;
    CGSize size = CGSizeMake(AppWidth-10,CGFLOAT_MAX);
    CGSize labelsize = [textStr sizeWithFont:font constrainedToSize:size lineBreakMode:label.lineBreakMode];
    label.frame = CGRectMake(5,30, labelsize.width, labelsize.height);
    label.text = textStr;
    return label;
}

+(UIImage *)getImageByColor:(UIColor*)color
{
    CGRect rect = CGRectMake(0, 0, 1, 1);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

+(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize
{
    UIGraphicsBeginImageContext(newSize);
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage;
}

@end
